﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using DataBaseLibrary.DBObjectsFB;
using DataBaseLibrary.DBInterfaces;

namespace DocMreoLiteVersion.Controls
{


    public class ActionToValueConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            ApplicationVu.ActionIssue valIssue = (ApplicationVu.ActionIssue)value;
            return (int) valIssue;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return (ApplicationVu.ActionIssue)value;
        }
    }


    /// <summary>
    /// Interaction logic for DrivingLicenseControl.xaml
    /// </summary>
    public partial class DrivingLicenseControl : UserControl
    {


        private ApplicationVu mApplicationVuObject;

        public ApplicationVu ApplicationVuObject
        {
            set
            {
                DataContext = value;
                mApplicationVuObject = value;
            }
            get { return mApplicationVuObject; }
        }


        public DrivingLicenseControl()
        {
            InitializeComponent();
        }



        private void TextBox_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Enter)
            {
                const FocusNavigationDirection focusNav = FocusNavigationDirection.Next;
                var request = new TraversalRequest(focusNav);

                //ComboBox <Enter>
                if ((sender as ComboBox) != null && (sender as ComboBox).IsEditable)
                {

                    (sender as ComboBox).IsEditable = false;
                    (sender as UIElement).MoveFocus(request);
                    (sender as ComboBox).IsEditable = true;

                    e.Handled = true;
                    return;
                }

                if ((sender as UIElement) != null)
                    (sender as UIElement).MoveFocus(request);



                e.Handled = true;
            }

        }


    }
}
